# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Gobidev <adrian[dot]groh[at]t-online[dot]de>
# Contributor: Hao Long <aur@esd.cc>

pkgname=rustscan
pkgver=2.1.1
pkgrel=1
pkgdesc='A modern port scanner'
arch=('loong64' 'x86_64')
url='https://github.com/rustscan/RustScan'
license=('GPL3')
depends=('gcc-libs' 'nmap')
makedepends=('git' 'rust')
checkdepends=('python')
options=('!lto')
_commit='bd32f4ead4edd662633c1dd1f569132352ed9f04'
source=(
  "$pkgname::git+$url#commit=$_commit"
  'update-lockfile.patch'
)
b2sums=('SKIP'
        '2e9ee58867414ffc5148e4c4213a4cf1641961a9f540e201cc6311011b19fd32559e9af668aae514b13b53f024bd51764bb0853501dd7919f305aa71a17066f0')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  # update out-of-sync lockfile
  # https://github.com/RustScan/RustScan/issues/460
  patch -p1 -i ../update-lockfile.patch

  # download dependencies
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname"

  cargo build --frozen --release --all-features
}

check() {
  cd "$pkgname"

  cargo test --frozen --all-features
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" target/release/rustscan
}
